<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <style>
        .red{
            background: red;
            /* font-size: 50px; */
            /* line-height: 100px; */
        }
        .teal{
            background: teal;
            /* font-size: 50px; */
            /* line-height: 100px; */
            color: #fff;
        }
        *{
            list-style: none;
        }
        .c li {
            width: 200px;
            height: 100px;
            margin: 20px;
            padding: 20px;
            border: 1px solid orange;
           display: inline-block;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- :class="变量" 不常用-->
        <div :class="bg">明天星期五</div>

        <!-- :class='[三目判断]' -->
        <div :class="[isRed ? 'red' : 'teal']">后天星期六</div>

        <!-- 动态类名：数组方式三目 :class='[三目判断]' -->
        <button @click="changeColor()">炫彩切换</button>
        <div :class="[isRed ? 'red' : 'teal']">炫彩切换</div>

        <h1> 使用场景：隔行变色 </h1>
        <ul class="c">
            <li v-for="(item,index) in course" :key="item.id" :class="[index%2==0 ?'red':'teal']">
                <!-- index:0  red
                     index:1   teal
                     index:2   red
                     index:3   teal
                     index:4   red
                 -->
                <p>课程名称:{{item.title}}</p>
                <p>课程价格:{{item.price == 0 ? "免费" : item.price}}</p>
            </li>
        </ul>

        <h1>案例：三行一变身：orange，yellow，</h1>

    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                bg:"red",
                isRed:false,
                 //课程
                 course: [
                    {
                        id: 1,
                        title: "暑假班",
                        price: 200
                    },
                    {
                        id: 2,
                        title: "英语特长班",
                        price: 0
                    },
                    {
                        id: 3,
                        title: "疯狂屋里",
                        price: 299
                    },
                    {
                        id: 4,
                        title: "疯狂化学",
                        price: 1000
                    }
                ]
            },
            methods:{
                changeColor(){
                    this.isRed = !this.isRed;
                }
            }
        })
    </script>
</body>
</html>